<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center learningRecord_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub learningRecord_fd0_0'>
				<view class='flex flex-wrap align-center justify-center learningRecord_fd0_0_c0'
					@tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  learningRecord_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-center'>
					<text class='learningRecord_fd0_0_c1_c0' v-if="type=='1'">学习记录</text><text
						class='learningRecord_fd0_0_c1_c0' v-if="type=='2'">考试记录</text>
				</view>
				<view class='flex flex-wrap align-center learningRecord_fd0_0_c0'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#cd962d"></u-loading>
			<view class="loading_text">加载中</view>
		</view>
		<block v-else>
			<!---学习记录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout learningRecord_flex_1"
				v-if="type=='1'">
				<view class='flex flex-wrap align-center justify-end learningRecord_fd1_0' v-for="(v, k) in list" :key="k" @tap.stop="handleJumpDiy"
					data-type="navigateTo" :data-url="`/pages/course/courseDetails/courseDetails?aid=${v.course_id}`">
					<view class='flex flex-wrap align-center learningRecord_fd1_0_c0'>
						<image class='learningRecord_fd1_0_c0_c0' mode="aspectFill" :src='v.thumb'></image>
						<view class='flex flex-wrap align-center justify-center learningRecord_fd1_0_c0_c1' v-if="v.is_study == 1">
							<text class='learningRecord_fd1_0_c0_c1_c0'>必学</text>
						</view>
					</view>
					<view class='flex flex-direction flex-wrap align-stretch flex-sub'>
						<view class='flex flex-wrap align-center justify-between'>
							<text class='learningRecord_fd1_0_c1_c0_c0'>{{v.course_name}}</text>
							<button class='learningRecord_fd1_0_c1_c0_c1'>重新学习</button>
						</view>
						<view class='flex flex-wrap align-center justify-between learningRecord_fd1_0_c1_c1'>
							<view class='flex flex-wrap align-center'>
								<text class='learningRecord_fd1_0_c1_c1_c0_c0'>共</text>
								<text class='learningRecord_fd1_0_c1_c1_c0_c0'>{{v.chapter_num}}</text>
								<text class='learningRecord_fd1_0_c1_c1_c0_c0'>章节</text>
							</view>
						</view>
						<view class='flex flex-wrap align-center learningRecord_fd1_0_c1_c2'>
							<text class='learningRecord_fd1_0_c1_c1_c0_c0'>最近学习完成：</text>
							<text class='learningRecord_fd1_0_c1_c1_c0_c0'>{{v.create_time}}</text>
						</view>
					</view>
				</view>
				<u-loadmore v-if="last_page > 1" class="loadmore" font-size="24" :status="status"
					:icon-type="iconType" :load-text="loadText" />
				<view class="noData" v-if="list.length == 0 && !isShow">
					<image src="/static/empty/no.png"></image>
					<view>没有学习记录~</view>
				</view>
			</view>
			
			<!---学习记录flex布局结束-->
			<!---考试记录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout learningRecord_flex_2"
				v-if="type=='2'">
				<view class='flex flex-wrap align-center justify-end learningRecord_fd2_0' v-for="(v, k) in examList" :key="k" @tap.stop="handleJumpDiy"
					data-type="navigateTo" :data-url="`/pages/course/result/result?aid=${v.aid}&type=2`">
					<view class='learningRecord_fd2_0_c0'>
						<image class='learningRecord_fd2_0_c0_c0' mode="aspectFill" :src='v.examtask_img_url'></image>
					</view>
					<view class='flex flex-direction flex-wrap align-stretch flex-sub'>
						<view class='flex flex-wrap align-center justify-between learningRecord_fd2_0_c1_c0'>
							<text class='learningRecord_fd2_0_c1_c0_c0'>{{v.examtask_name}}</text>
						</view>
						<view class='flex flex-wrap align-center learningRecord_fd2_0_c1_c1'>
							<text class='learningRecord_fd2_0_c1_c1_c0'>考试成绩：</text>
							<text class='learningRecord_fd2_0_c1_c1_c1'>{{v.score}}</text>
						</view>
						<view class='flex flex-wrap align-center'>
							<text class='learningRecord_fd2_0_c1_c1_c1'>考试时间：</text>
							<text class='learningRecord_fd2_0_c1_c1_c1'>{{v.create_time}}</text>
						</view>
					</view>
				</view>
				<u-loadmore v-if="last_page > 1" class="loadmore" font-size="24" :status="status"
					:icon-type="iconType" :load-text="loadText" />
				<view class="noData" v-if="examList.length == 0 && !isShow">
					<image src="/static/empty/no.png"></image>
					<view>没有考试记录~</view>
				</view>
			</view>
			
			<!---考试记录flex布局结束-->
		</block>
	</view>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				"type": "1",
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": true,
				"examList": [],  // 考试记录
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				type
			} = options
			if (type !== undefined) this.type = type;
			if (this.type == 1) {
				this.getStudyRecord();
			} else {
				this.examRecord();
			}
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			if (this.type == 1) {
				this.getStudyRecord();
			} else {
				this.examRecord();
			}
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				if (this.type == 1) {
					this.getStudyRecord();
				} else {
					this.examRecord();
				}
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			// 获取学习记录  post647f156ba48ec
			getStudyRecord() {
				this.$api.post(global.apiUrls.post647f156ba48ec, {
					page: this.page
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 获取考试记录  post649046bcadcc2
			examRecord() {
				this.$api.post(global.apiUrls.post649046bcadcc2, {
					page: this.page
				}).then(res => {
					console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.examList = res.data.data.data;
						} else {
							this.examList = this.examList.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor1);
		background-size: 100% auto !important;
	}

	.learningRecord_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.learningRecord_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		line-height: 88rpx;
	}

	.learningRecord_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.learningRecord_fd0_0_c0 {
		width: 50rpx;
		height: 50rpx;
	}

	.learningRecord_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.learningRecord_flex_1 {
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.learningRecord_fd1_0_c1_c2 {
		margin: 16rpx 0rpx 0rpx 0rpx;
	}

	.learningRecord_fd1_0_c1_c1_c0_c0 {
		color: #636363;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.learningRecord_fd1_0_c1_c1 {
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.learningRecord_fd1_0_c1_c0_c1 {
		border: 1px solid #1D89EB;
		border-radius: 64rpx 64rpx 64rpx 64rpx;
		width: 120rpx;
		line-height: 48rpx;
		font-size: 22rpx;
		color: rgba(42, 139, 238, 1);
		height: 48rpx;
	}

	.learningRecord_fd1_0_c1_c0_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 700;
		line-height: 40rpx;
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.learningRecord_fd1_0_c0_c1_c0 {
		color: #FFFFFF;
		font-size: 20rpx;
		font-weight: 400;
		line-height: 28rpx;
	}

	.learningRecord_fd1_0_c0_c1 {
		background: linear-gradient(180deg, #F14B0B 0%, #E3271D 100%);
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		width: 64rpx;
		height: 32rpx;
		position: absolute;
		top: 0rpx;
		left: 12rpx;
	}

	.learningRecord_fd1_0_c0_c0 {
		width: 258rpx;
		height: 160rpx;
		border-radius: 16rpx;
	}

	.learningRecord_fd1_0_c0 {
		border-radius: 16rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
		position: relative;
	}

	.learningRecord_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.learningRecord_flex_2 {
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.learningRecord_fd2_0_c1_c1_c1 {
		color: #636363;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.learningRecord_fd2_0_c1_c1_c0 {
		color: #636363;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.learningRecord_fd2_0_c1_c1 {
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.learningRecord_fd2_0_c1_c0_c0 {
		color: #333333;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.learningRecord_fd2_0_c1_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.learningRecord_fd2_0_c0_c0 {
		width: 258rpx;
		height: 160rpx;
		border-radius: 16rpx;
	}

	.learningRecord_fd2_0_c0 {
		border-radius: 16rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
		position: relative;
	}

	.learningRecord_fd2_0 {
		margin: 22rpx 0rpx 22rpx 0rpx;
	}
</style>